$OpenBSD: patch-src_sets_bitset_c,v 1.1.1.1 2011/11/17 17:12:11 kili Exp $

Python-2.7 fix from upstream svn and from debian bug tracker.

--- src/sets/bitset.c.orig	Thu Jun 18 17:20:43 2009
+++ src/sets/bitset.c	Wed Nov 16 16:26:34 2011
@@ -2011,13 +2011,21 @@ mutbitset_iop_PyLongObject(NyMutBitSetObject *ms, int 
 {
     NyBits *buf;
     int r = -1;
+#if PY_VERSION_HEX >= 0x02070000
+    Py_ssize_t e;
+#else
     int e;
+#endif
     long num_poses, num_bytes;
     double num_bits, x;
     int cpl = 0;
     PyObject *w = 0;
     
-    x = _PyLong_AsScaledDouble(v, &e);
+#if PY_VERSION_HEX >= 0x02070000
+	x = _PyLong_Frexp(v, &e);
+#else
+	x = _PyLong_AsScaledDouble(v, &e);
+#endif
     if (x == -1 && PyErr_Occurred())
       return -1;
     if (x < 0) {
@@ -2026,15 +2034,24 @@ mutbitset_iop_PyLongObject(NyMutBitSetObject *ms, int 
 	w = PyNumber_Invert(v);
 	if (!w) return -1;
 	v = w;
+#if PY_VERSION_HEX >= 0x02070000
+	x = _PyLong_Frexp(v, &e);
+#else
 	x = _PyLong_AsScaledDouble(v, &e);
+#endif
 	if (x == -1 && PyErr_Occurred())
 	  return -1;
 	assert(x >= 0);
     }
-    if (x != 0)
-      num_bits = 1.0 * e * SHIFT + log(x)/log(2) + 1;
+    if (x != 0) {
+	num_bits = e;
+#if PY_VERSION_HEX < 0x02070000
+	num_bits *= SHIFT;
+#endif
+	num_bits += log(x)/log(2) + 1;
+    }
     else
-      num_bits = 0;
+	num_bits = 0;
 	
     num_poses = (long)(num_bits / NyBits_N + 1);
     /* fprintf(stderr, "x %f e %d num_bits %f num_poses %ld\n", x, e, num_bits, num_poses); */
